package model.model02.demo01;

import java.util.Scanner;

public class Main {
    static double allTotal = 0.0;
    public static void main(String[] args) {
        do {
            double total = 0.0;
            Scanner sc = new Scanner(System.in);
            System.out.print("请输入单价: ");
            double unitPrice = sc.nextDouble();

            System.out.print("请输入数量: ");
            int number = sc.nextInt();

            System.out.print("请输入折扣(0: 正常收费, 1: 打八折, 2: 打七折, 3: 打六折): ");
            int discount = sc.nextInt();

            switch (discount) {
                case 0: total = unitPrice * number; break;
                case 1: total = (unitPrice * number) * 0.8; break;
                case 2: total = (unitPrice * number) * 0.7; break;
                case 3: total = (unitPrice * number) * 0.6; break;
                default:
                    System.out.println("暂无对应折扣");
            }

            System.out.println("单价: " + unitPrice + ", 数量: " + number + ", 合计: " + total);
            allTotal += total;

            System.out.println("是否退出购物(0: 退出, 1: 继续购物): ");
            int flag = sc.nextInt();
            if (flag == 0) {
                break;
            }
        } while (true);

        System.out.println("本次购物结束,总计: " + allTotal);
    }
}
